<template>
  <el-form-item :label-width="item.labelWidth?item.labelWidth:'130px'" :label="item.title" :prop="rules?item.field:''">
    <span slot="label">{{item.title}}
      <el-tooltip v-if="item.info" :content="item.info" placement="top">
        <span class="fas fa-info-circle color"></span>
      </el-tooltip>
    </span>
    <el-input v-model="form[item.field]" :disabled="disabled" @change="change"></el-input>
  </el-form-item>
</template>

<script>
export default {
  // name: 'text'
  props: ['item', 'form', 'rules', 'disabled'],
  methods: {
    change(v) {
      if (this.item.itemChange) {
        this.item.itemChange(this.form, this.item, v);
      }
    }
  },
  mounted() {
    this.rules && this.rules[this.item.field] && this.rules[this.item.field].push({ pattern: /^[0-9]+$/, message: '只能输入数字', trigger: 'blur' })
    this.rules && this.rules[this.item.field] && this.rules[this.item.field].push({ min: 1, max: 2, message: '长度在 1 到 2个字符', trigger: 'blur' })

    // if (!this.rules) {
    //   this.rules = {}
    // }
    // if (!this.rules[this.item.field]) {
    //   this.rules[this.item.field] = []
    // }
    // this.rules && this.rules[this.item.field].push({ pattern: /^[0-9]+$/, message: '只能输入数字', trigger: 'blur' })
    // this.rules && this.rules[this.item.field].push({ min: 1, max: 2, message: '长度在 1 到 2个字符', trigger: 'blur' })
  }
}
</script>

<style>

</style>
